package com.house.business.controller;

import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.house.business.service.NoticeService;
import com.house.business.entity.Notice;
import com.house.business.vo.NoticeVo;
import org.springframework.web.bind.annotation.RestController;
import com.house.framework.controller.BaseController;

/**
 * <p>
 * 公告表 前端控制器
 * </p>
 *
 * @since 2023-05-09
 */
@Slf4j
@RestController
@RequestMapping("/noticeController")
public class NoticeController extends BaseController {

    @Autowired
    private NoticeService noticeService;
    /**
    * 新增公告表
    * @param entity
    * t_notice新增数据
    * @return 新增数据id
    */
    @ApiOperation(value = "公告表", notes = "新增公告表")
    @RequestMapping(value = "/addNotice", method = RequestMethod.POST)
    public Object addNotice(@RequestBody Notice entity) {
        return noticeService.addNotice(entity);
    }

    /**
    * 修改公告表
    * @param entity
    * t_notice修改数据
    * @return 修改记录数
    */
    @ApiOperation(value = "公告表", notes = "修改公告表")
    @RequestMapping(value = "/updateNotice", method = RequestMethod.POST)
    public Object updateNotice(@RequestBody Notice entity) {
        return noticeService.updateNotice(entity);
    }

    /**
    * 取指定ID的公告表数据
    * @param id
    * t_notice 主键ID
    * @return 返回实体对象
    * 返回指定id 公告表数据
    */
    @ApiOperation(value = "公告表", notes = "取公告表")
    @RequestMapping(value = "/getNoticeById", method = RequestMethod.GET)
    public NoticeVo getNoticeById(@RequestParam Long id) {
        return noticeService.getNoticeById(id);
    }

    /**
    * 公告表分页取数
    * @param entityVo
    * t_notice 分页取数参数，pageIndex=页码；pageSize=每页记录数；
    * @return
    * 返回分页数据
    */
    @RequestMapping(value = "/getNoticeList", method = RequestMethod.POST)
    public IPage<NoticeVo> getNoticeList(@RequestBody NoticeVo entityVo){
        IPage<NoticeVo> page = noticeService.getNoticeList(entityVo);
        return page;
    }

    /**
    * 删除指定ID的公告表数据
    * @param id
    * t_notice 主键ID
    */
    @ApiOperation(value = "公告表", notes = "删除公告表")
    @RequestMapping(value = "/deleteNoticeById/{id}", method = RequestMethod.GET)
    public void deleteNoticeById(@PathVariable("id") Long id) {
         noticeService.deleteNoticeById(id);
    }

    /**
    * 批量删除指定ID的公告表数据
    * @param ids
    * t_notice 主键ID
    */
    @ApiOperation(value = "公告表", notes = "批量删除公告表")
    @RequestMapping(value = "/batchDelete", method = RequestMethod.POST)
    public void batchDelete(@RequestParam Long[] ids) {
        noticeService.batchDelete(ids);
    }

}
